
public class AmmoWeapon extends Weapon 
{
	private int shots;
	private int capacity;
	private int reloads;
	
	public AmmoWeapon()
	{
		super();
		this.capacity = 6;
		this.shots = this.capacity;
		this.reloads = 1;
	}
	
	public AmmoWeapon(int toHit, int diceNum, int diceSides, int damBonus, int capacity, int reloads)
	{
		super(toHit, diceNum, diceSides, damBonus);
		this.capacity = capacity;
		this.shots = this.capacity;
		this.reloads = reloads;
		
	}
	
	public AmmoWeapon(int toHit, int diceNum, int diceSides, int damBonus, int useCost, int energyCost, int weight,
			int capacity, int reloads)
	{
		super(toHit, diceNum, diceSides, damBonus, useCost,energyCost, weight);
		this.capacity = capacity;
		this.shots = this.capacity;
		this.reloads = reloads;
	}
	
	public int getShots()
	{
		return this.shots;
	}
	
	/**
	 * reduces ammo of weapon
	 * @return
	 */
	public boolean fire()
	{
		if(this.shots > 0)
		{
			this.shots--;
			return true;
		}
		else
		{
			return false;
		}
	}
	
	/**
	 * produces an attack if weapon is loaded
	 */
	public Attack attack()
	{
		
		if(fire()){return super.attack();}
		else {return null;}
	}
	
	/**
	 * reloads the weapon
	 */
	public void reload()
	{
		if(this.reloads > 0)
		{
			this.reloads--;
			this.shots = this.capacity;
		}
		else
		{
			System.out.println("cant reload");
		}
	}
	
	public String toString()
	{
		return super.toString() + this.shots + "/" + this.capacity + "(" + reloads + ")";
	}
}
